home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk122 / popup / source / highlight.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  2KB  |  77 lines

  1. #include "PopUpMenu.h"
  2.  
  3. /**************************************************
  4.  * HighLightItem(Item, ItemWindow, Mode)          *
  5.  *                          *
  6.  * Input:                      *
  7.  *   Item  -      Item to highlight.          *
  8.  *   ItemWindow - Data for the window to draw in. *
  9.  *   Mode   -      HIGHLIGHTON or HIGHLIGHTOFF.      *
  10.  * Output:                      *
  11.  *   none                      *
  12.  **************************************************/
  13. VOID HighLightItem(Item, ItemWindow, Mode)
  14.   struct MenuItem *const Item;
  15.   struct WindowData  *const ItemWindow;
  16.   const UWORD Mode;
  17. {
  18.   IMPORT struct RastPort Rp;
  19.  
  20.   /* possible to highlight item ? */
  21.   if (Item->Flags & ITEMENABLED) {
  22.     const LONG Left   = Item->LeftEdge - ItemWindow->LeftValue;
  23.     const LONG Right  = Left + Item->Width;
  24.     const LONG Top    = Item->TopEdge - ItemWindow->TopValue;
  25.     const LONG Bottom = Top + Item->Height;
  26.  
  27.     SetDrMd(&Rp, COMPLEMENT);
  28.  
  29.     switch (Item->Flags & HIGHFLAGS) {
  30.       case HIGHCOMP:
  31.     RectFill(&Rp, Left, Top, Right - 1, Bottom - 1);
  32.     break;
  33.       case HIGHBOX:
  34.     Move(&Rp, Left  - 1, Top - 2);
  35.     Draw(&Rp, Right + 1, Top - 2);
  36.     Draw(&Rp, Right + 1, Bottom + 1);
  37.     Draw(&Rp, Left  - 1, Bottom + 1);
  38.     Draw(&Rp, Left  - 1, Top - 1);
  39.     Draw(&Rp, Right    , Top - 1);
  40.     Draw(&Rp, Right    , Bottom);
  41.     Draw(&Rp, Left     , Bottom);
  42.     Draw(&Rp, Left     , Top);
  43.     break;
  44.       case HIGHIMAGE:
  45.     DrawMenuItem(Item, ItemWindow, (UWORD)(!Mode),CLEAROLD);
  46.     }
  47.   }
  48. }
  49.  
  50. /*********************************************
  51.  * ToggleMenu(Number,Menu)                   *
  52.  *                         *
  53.  * Input:                     *
  54.  *   Number - Menu to highlight.         *
  55.  *   Menu   - Pointer to the Menu structure. *
  56.  * Output:                     *
  57.  *   none                     *
  58.  *********************************************/
  59. VOID ToggleMenu(Number,Menu)
  60.   const UWORD Number;
  61.   struct Menu *const Menu;
  62. {
  63.   IMPORT struct WindowData  MenuWindow;
  64.   IMPORT struct RastPort Rp;
  65.   IMPORT const UWORD  MenuFontSize;
  66.  
  67.   if (Menu->Flags & MENUENABLED) {
  68.     const LONG Bottom = MenuWindow.TopEdge + Number * MenuFontSize;
  69.     const LONG Top    = Bottom - MenuFontSize + BORDERSIZE;
  70.  
  71.     SetDrMd(&Rp, COMPLEMENT);
  72.     RectFill(&Rp, (LONG)MenuWindow.LeftEdge  + BORDERSIZE, Top,
  73.           (LONG)MenuWindow.RightEdge - BORDERSIZE, Bottom);
  74.   }
  75. }
  76.  
  77.